<?php 


include './function.php';
$code = $_GET['code'];
$code = '8C3647365689B5C3C8FC1076FFABC040';
// Step3：通过Authorization Code获取Access Token
$token_url = 'https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=*************&client_secret=*********&code='.$code.'&state=****&redirect_uri=httphttp://www.lampnshare.cn/qq';
// $token_res = https_request($token_url);
var_dump($token_res);
$data = explode('&', $token_res);
$data = explode('=', $data[0]);
$token = $data[1];
// var_dump($token);
// $token = '8DE3118DFA005A2E86AE552E04994EFC';
// Step4：使用Access Token来获取用户的OpenID
$openid_url = 'https://graph.qq.com/oauth2.0/me?access_token='.$token;
$openid_res = https_request($openid_url);
echo "<hr>";
var_dump($openid_res);
     if (strpos($openid_res, "callback") !== false)
     {
        $lpos = strpos($openid_res, "(");
        $rpos = strrpos($openid_res, ")");
        $openid_res  = substr($openid_res, $lpos + 1, $rpos - $lpos -1);
        $msg = json_decode($openid_res,true);
       
     }

     var_dump($msg);
     echo "<hr>";

$openid = $msg['openid'];

// Step5：使用Access Token以及OpenID来访问和修改用户数据
$userinfo_url = 'https://graph.qq.com/user/get_user_info?access_token='.$token.'&oauth_consumer_key=101358884&openid='.$openid;
$userinfo_res = https_request($userinfo_url);
echo "<hr>";
var_dump($userinfo_res);


http://qzapp.qlogo.cn/qzapp/101358884/1FAF575E164EBB13EA1BA0ACF9AF546E/30

 ?>